package com.mall.commons.result;

/**
 * @description: TODO
 * @author: jiaolei
 * @date: 2021/12/12 21:21
 */
public class GoodsResponseUtil<T> {
    private GoodsResponseData<T> responseData;

    public GoodsResponseUtil() {
        responseData = new GoodsResponseData<>();
        responseData.setSuccess(true);
        responseData.setMessage("success");
        responseData.setCode(200);
    }

    public GoodsResponseData<T> setData(T t) {
        this.responseData.setResult(t);
        this.responseData.setSuccess(true);
        responseData.setCode(200);
        return this.responseData;
    }

    public GoodsResponseData<T> setData(T t, String msg) {
        this.responseData.setResult(t);
        this.responseData.setSuccess(true);
        this.responseData.setMessage(msg);
        responseData.setCode(200);
        return this.responseData;
    }

    public GoodsResponseData<T> setData(T t,Long timestamp) {
        this.responseData.setResult(t);
        this.responseData.setSuccess(true);
        responseData.setCode(200);
        responseData.setTimestamp(timestamp);
        return this.responseData;
    }

    public GoodsResponseData<T> setData(T t, String msg,Long timestamp) {
        this.responseData.setResult(t);
        this.responseData.setSuccess(true);
        this.responseData.setMessage(msg);
        responseData.setCode(200);
        responseData.setTimestamp(timestamp);
        return this.responseData;
    }

    public GoodsResponseData<T> setErrorMsg(String msg) {
        this.responseData.setSuccess(false);
        this.responseData.setMessage(msg);
        responseData.setCode(500);
        return this.responseData;
    }
    public GoodsResponseData<T> setErrorMsg(String msg,Long timeStamp) {
        this.responseData.setSuccess(false);
        this.responseData.setMessage(msg);
        responseData.setCode(500);
        responseData.setTimestamp(timeStamp);
        return this.responseData;
    }

    public GoodsResponseData<T> setErrorMsg(Integer code, String msg) {
        this.responseData.setSuccess(false);
        this.responseData.setMessage(msg);
        responseData.setCode(500);
        return this.responseData;
    }
}
